{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from Scripts.predictor import GenerateQADoc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pretrained_path = 'pubmed_pmc_470k/'\n",
    "ffn_weight_file = None\n",
    "bert_ffn_weight_file = 'models/bertffn_crossentropy/bertffn'\n",
    "embedding_file = 'qa_embeddings/bertffn_crossentropy.pkl'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "doc = GenerateQADoc(pretrained_path=pretrained_path,\n",
    "                    ffn_weight_file=None,\n",
    "                    bert_ffn_weight_file=bert_ffn_weight_file,\n",
    "                    embedding_file=embedding_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#@markdown Type in your question (maximum of 512 words)\n",
    "inputText = 'My eyes get super dry when I sleep. Any solutions?' #@param {type:\"string\"}\n",
    "#@markdown Return top k results\n",
    "k = 5 #@param {type:\"number\"}\n",
    "#@markdown Perform similarity search by answers or questions? \n",
    "search_byI = 'answer' #@param [\"answer\", \"question\"]\n",
    "#@markdown Do you want only answers returned? \n",
    "answerOnly = False #@param [\"False\", \"True\"] {type:\"raw\"}\n",
    "\n",
    "\n",
    "advices = doc.predict( inputText , search_by=search_byI, topk=k, answer_only=answerOnly)\n",
    "\n",
    "for kj in advices:\n",
    "    print('')\n",
    "    print(kj)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:tf]",
   "language": "python",
   "name": "conda-env-tf-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
